#include <hxcpp.h>

#ifndef INCLUDED_Std
#include <Std.h>
#endif
#ifndef INCLUDED_StringBuf
#include <StringBuf.h>
#endif
#ifndef INCLUDED_Sys
#include <Sys.h>
#endif
#ifndef INCLUDED_jax_io_JCloseable
#include <jax/io/JCloseable.h>
#endif
#ifndef INCLUDED_jax_io_JFilterOutputStream
#include <jax/io/JFilterOutputStream.h>
#endif
#ifndef INCLUDED_jax_io_JOutputStream
#include <jax/io/JOutputStream.h>
#endif
#ifndef INCLUDED_jax_io_JPrintStream
#include <jax/io/JPrintStream.h>
#endif
#ifndef INCLUDED_jax_lang_JAutoClosable
#include <jax/lang/JAutoClosable.h>
#endif
#ifndef INCLUDED_jax_lang_JOutputStream
#include <jax/lang/JOutputStream.h>
#endif
namespace jax{
namespace lang{

Void JOutputStream_obj::__construct()
{
{
	HX_SOURCE_POS("Source/jax/lang/JSystem.hx",30)
	this->buff = ::StringBuf_obj::__new();
}
;
	return null();
}

JOutputStream_obj::~JOutputStream_obj() { }

Dynamic JOutputStream_obj::__CreateEmpty() { return  new JOutputStream_obj; }
hx::ObjectPtr< JOutputStream_obj > JOutputStream_obj::__new()
{  hx::ObjectPtr< JOutputStream_obj > result = new JOutputStream_obj();
	result->__construct();
	return result;}

Dynamic JOutputStream_obj::__Create(hx::DynamicArray inArgs)
{  hx::ObjectPtr< JOutputStream_obj > result = new JOutputStream_obj();
	result->__construct();
	return result;}

hx::Object *JOutputStream_obj::__ToInterface(const type_info &inType) {
	if (inType==typeid( ::jax::io::JPrintStream_obj)) return operator ::jax::io::JPrintStream_obj *();
	return super::__ToInterface(inType);
}

Void JOutputStream_obj::println( Dynamic s){
{
		HX_SOURCE_PUSH("JOutputStream_obj::println")
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",34)
		this->print(s);
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",35)
		this->print(::jax::lang::JOutputStream_obj::NEW_LINE);
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC1(JOutputStream_obj,println,(void))

Void JOutputStream_obj::print( Dynamic s){
{
		HX_SOURCE_PUSH("JOutputStream_obj::print")
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",38)
		::String as = ::Std_obj::string(s);
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",39)
		{
			HX_SOURCE_POS("Source/jax/lang/JSystem.hx",39)
			::StringBuf _this = this->buff;
			HX_SOURCE_POS("Source/jax/lang/JSystem.hx",39)
			hx::IndexRef((_this->b).mPtr,_this->b->__Field(HX_CSTRING("length"),true)) = as;
		}
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",40)
		if (((as.indexOf(::jax::lang::JOutputStream_obj::NEW_LINE,null()) == (int)-1))){
			HX_SOURCE_POS("Source/jax/lang/JSystem.hx",40)
			this->flush();
		}
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC1(JOutputStream_obj,print,(void))

Void JOutputStream_obj::flush( ){
{
		HX_SOURCE_PUSH("JOutputStream_obj::flush")
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",45)
		::String as = this->buff->b->__Field(HX_CSTRING("join"),true)(HX_CSTRING(""));
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",46)
		this->buff = ::StringBuf_obj::__new();
		HX_SOURCE_POS("Source/jax/lang/JSystem.hx",47)
		{
			HX_SOURCE_POS("Source/jax/lang/JSystem.hx",47)
			int _g = (int)0;
			Array< ::String > _g1 = as.split(HX_CSTRING("\n"));
			HX_SOURCE_POS("Source/jax/lang/JSystem.hx",47)
			while(((_g < _g1->length))){
				HX_SOURCE_POS("Source/jax/lang/JSystem.hx",47)
				::String l = _g1->__get(_g);
				HX_SOURCE_POS("Source/jax/lang/JSystem.hx",47)
				++(_g);
				HX_SOURCE_POS("Source/jax/lang/JSystem.hx",48)
				if (((l.length > (int)0))){
					HX_SOURCE_POS("Source/jax/lang/JSystem.hx",48)
					::Sys_obj::println(l);
				}
			}
		}
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC0(JOutputStream_obj,flush,(void))

::String JOutputStream_obj::NEW_LINE;


JOutputStream_obj::JOutputStream_obj()
{
}

void JOutputStream_obj::__Mark(HX_MARK_PARAMS)
{
	HX_MARK_BEGIN_CLASS(JOutputStream);
	HX_MARK_MEMBER_NAME(buff,"buff");
	HX_MARK_END_CLASS();
}

void JOutputStream_obj::__Visit(HX_VISIT_PARAMS)
{
	HX_VISIT_MEMBER_NAME(buff,"buff");
}

Dynamic JOutputStream_obj::__Field(const ::String &inName,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"buff") ) { return buff; }
		break;
	case 5:
		if (HX_FIELD_EQ(inName,"print") ) { return print_dyn(); }
		if (HX_FIELD_EQ(inName,"flush") ) { return flush_dyn(); }
		break;
	case 7:
		if (HX_FIELD_EQ(inName,"println") ) { return println_dyn(); }
		break;
	case 8:
		if (HX_FIELD_EQ(inName,"NEW_LINE") ) { return NEW_LINE; }
	}
	return super::__Field(inName,inCallProp);
}

Dynamic JOutputStream_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"buff") ) { buff=inValue.Cast< ::StringBuf >(); return inValue; }
		break;
	case 8:
		if (HX_FIELD_EQ(inName,"NEW_LINE") ) { NEW_LINE=inValue.Cast< ::String >(); return inValue; }
	}
	return super::__SetField(inName,inValue,inCallProp);
}

void JOutputStream_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("buff"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	HX_CSTRING("NEW_LINE"),
	String(null()) };

static ::String sMemberFields[] = {
	HX_CSTRING("buff"),
	HX_CSTRING("println"),
	HX_CSTRING("print"),
	HX_CSTRING("flush"),
	String(null()) };

static void sMarkStatics(HX_MARK_PARAMS) {
	HX_MARK_MEMBER_NAME(JOutputStream_obj::NEW_LINE,"NEW_LINE");
};

static void sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(JOutputStream_obj::__mClass,"__mClass");
	HX_VISIT_MEMBER_NAME(JOutputStream_obj::NEW_LINE,"NEW_LINE");
};

Class JOutputStream_obj::__mClass;

void JOutputStream_obj::__register()
{
	Static(__mClass) = hx::RegisterClass(HX_CSTRING("jax.lang.JOutputStream"), hx::TCanCast< JOutputStream_obj> ,sStaticFields,sMemberFields,
	&__CreateEmpty, &__Create,
	&super::__SGetClass(), 0, sMarkStatics, sVisitStatics);
}

void JOutputStream_obj::__boot()
{
	hx::Static(NEW_LINE) = HX_CSTRING("\n");
}

} // end namespace jax
} // end namespace lang
